<?php

use think\migration\Migrator;
use think\migration\db\Column;

class ConfigType extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        // create the table
        $table = $this->table('config_type', ['engine' => 'MyISAM']);
        $table->addColumn('zh_name', 'string', ['limit' => 60, 'default' => '', 'comment' => '配置项类型中文名'])
            ->addColumn('en_name', 'string', ['limit' => 60, 'default' => '', 'comment' => '配置项类型英文名'])
            ->addColumn('sort', 'integer', ['limit' => 3, 'default' => 0, 'comment' => '配置项类型排序'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '配置项状态。1:正常；0:禁止'])
            ->addColumn('delete_time', 'datetime', ['default' => null, 'comment' => '软删除'])
            ->addIndex(['zh_name'], ['unique' => TRUE])
            ->addIndex(['en_name'], ['unique' => TRUE])
            ->create();
    }
}
